package br.brpv.silvestrin.conferencia.helper;

import java.util.zip.Inflater;

import org.apache.commons.codec.binary.Base64;

public class Compression {
	public static String decompress(String compressed) {
		Inflater decompresser = new Inflater();
		decompresser.setInput(Base64.decodeBase64(compressed.getBytes()), 0,
				Base64.decodeBase64(compressed.getBytes()).length);
		byte[] result = new byte[100000]; //TODO Ver isso.
		String resultString = "";
		int resultLength = 0;

		try {
			resultLength = decompresser.inflate(result);
			resultString = new String(result, 0, resultLength, "UTF-8");
		} catch (Exception e) {
			e.printStackTrace();
		}
		decompresser.end();

		return resultString;
	}
}
